$(function(){
	patientvisitdetail();
	function patientvisitdetail(){
		var infoid =utilModule.getQueryString("infoid");
		var param = {"infoid":infoid};
		function callBack(data){
			console.log(data);
			var info = data.patientVisitInfo;
			console.log(info);
			
			$(".Time").text(info.visitDate);
			var sfType=["门诊","家庭访问","电话","失访","死亡"];
			$(".visitType").text(sfType[info.visitType-1]);
			if(info.visitType==4){
				$(".box2").show();
			}else if(info.visitType==5){
				$(".box3").show();
			}else{
				$(".box1").show();
			}
			var zsInfo=["外出打工","迁居他处","走失","连续3次未访问到","其他"];
			$(".loseInfo").text(zsInfo[info.loseInfo-1]);
			if(!info.dieInfo == ""){
				var dieTime=JSON.parse(info.dieInfo);
				$(".dieTime").text(dieTime.d_time);
				var dieWhy=["躯干疾病","染病和寄生虫病","肿瘤","心脏病","脑血管病","呼吸系统疾病","消化系统疾病","其他疾病","不详","自杀","他杀","意外","精神疾病相关并发症","其他"];
				if(0<=dieTime.d_why&&dieTime.d_why<=8){
					$(".dieInfo").text("躯干疾病("+dieWhy[dieTime.d_why]+")");
				}else{
					$(".dieInfo").text(dieWhy[dieTime.d_why]);
				}
			}
			if(!info.riskInfo == ""){
				var wxRisk=JSON.parse(info.riskInfo);
				var symptom=["幻觉","交流困难","猜忌","喜怒无常","行为怪异","兴奋话多","伤人毁物","悲观厌世","无故外走","自语自笑","孤僻懒散","其他"]
				for(i in wxRisk){
					if(symptom[wxRisk[i]-1]==undefined){
						symptom[wxRisk[i]-1]=wxRisk.write;
					}
					$(".symptom").append(symptom[wxRisk[i]-1]+" ");
				}
			}
			if(!info.perception == ""){
				var zzPerception=["自知力完全","自知力不全","自知力缺失"];
				$(".perception").text(zzPerception[info.perception-1]);
			}
			if(!info.sleepStatus == ""){
				var smSleep=["良好","一般","较差"];
				$(".sleepStatus").text(smSleep[info.sleepStatus-1]);
			}
			if(!info.dietaryStatus == ""){
				var ysStatus=["良好","一般","较差"];
				$(".dietaryStatus").text(ysStatus[info.dietaryStatus-1]);
			}
			if(!info.socialInfo == ""){
				var social=JSON.parse(info.socialInfo);
				var grades=["0级","1级","2级","3级","4级","5级"];
				$(".grades").text(grades[social.grades]);
				var ysStatus=["良好","一般","较差"];
				$(".socialSh").text(ysStatus[social.shenghuo-1]);
				$(".socialJw").text(ysStatus[social.jiawu-1]);
				$(".socialLd").text(ysStatus[social.laodong-1]);
				$(".socialXx").text(ysStatus[social.xuexi-1]);
				$(".socialJi").text(ysStatus[social.jiaowang-1]);
				$(".socialYl").text(ysStatus[social.yilaxing-1]);
				$(".socialXg").text(ysStatus[social.xiaoguo-1]);
			}
			if(info.symptomInfo=="undefined" ||info.symptomInfo==""){
				$(".mqSymptoms").text("无");
			}else{
				var mqSymptoms=JSON.parse(info.symptomInfo);
				var symptomsName=[];
				symptomsName["qingdu"]="轻度滋事";
				symptomsName["zhaoshi"]="肇事";
				symptomsName["zhaohuo"]="肇祸";	
				symptomsName["qita"]="其他危害行为";
				symptomsName["zishang"]="自伤";
				symptomsName["zisha"]="自杀未遂";
				for(i in mqSymptoms){
					console.log(symptomsName[i])
					console.log(mqSymptoms[i])
					$(".mqSymptoms").append(symptomsName[i]+mqSymptoms[i]+"次 ");
				}
			}
			if(!info.isBelock==""){
				var lock=["无关锁","关锁","关锁已解除"];
				$(".lock").text(lock[info.isBelock-1]);
			}
			if(!info.inHospital==""){
				var lock=["未住院","目前正在住院","曾住院，现未住院"];
				$(".hospital").text(lock[info.inHospital]);
				if(info.inHospital==3){
					$(".leaveTime").show();
					$(".leaveTime font").text(info.leaveHosDate);
				}
			}
			if(!info.otherInfo==""){
				var other=JSON.parse(info.otherInfo);
				var lock=["无","有"];
				if(other.jiancha==1){
					$(".other").text(lock[other.jiancha-1]);
				}else{
					$(".other").text(lock[other.jiancha-1]+"("+other.jcDetail+")");
				}
				var compliance=["按医嘱规律服药","间歇服药","不服药","医嘱勿需服药"];
				$(".compliance").text(compliance[other.yilaxing-1]);
				if(other.fanying==1){
					$(".reaction").text(lock[other.fanying-1]);
				}else{
					$(".reaction").text(lock[other.fanying-1]+"("+other.fyDetail+")");
				}
				
				var effect=["痊愈","好转","无变化","加量"];
				$(".effect").text(effect[other.xiaoguo-1]);
				var zzlock=["否","是"];
				if(other.zhuanzhen==2){
					$(".diagnosis").text(zzlock[other.zhuanzhen-1]+"("+other.yuanyin+")");
				}else{
					$(".diagnosis").text("否");
				}
			}
			if(info.pharmacyInfo=="undefined"){
				$(".medication").html("暂无用药");
			}
			if(info.guidanceInfo=="undefined"){
				$(".medication2").html("暂无用药");
			}
			if(info.pharmacyInfo!="undefined" &&info.pharmacyInfo !=""){
				var html = "";
				var data = JSON.parse(info.pharmacyInfo);
				for (a in data) {
					var ma =  JSON.parse(data[a]);
					html +='<li class="medical"><div class="name"><span>药物名</span><font>'+ma.name+'</font></div><div class="cishu"><span>用法</span><font>每日'+ma.cishu+'次</font></div><div class="jiliang"><span>每次剂量</span><font>'+ma.jiliang+'mg</font></div></li>';
				}
				$(".medical-list").append(html);
			}
			if(info.guidanceInfo!="undefined" &&info.guidanceInfo !=""){
				var html = "";
				var data = JSON.parse(info.guidanceInfo);
				for (a in data) {
					var ma =  JSON.parse(data[a]);
					html +='<li class="medical"><div class="name"><span>药物名</span><font>'+ma.name+'</font></div><div class="cishu"><span>用法</span><font>每日'+ma.cishu+'次</font></div><div class="jiliang"><span>每次剂量</span><font>'+ma.jiliang+'mg</font></div></li>';
				}
				$(".medical-list2").append(html);
			}
			if(!info.recuperateMethod==""){
				var method=JSON.parse(info.recuperateMethod);
				var measures=["生活劳动能力","职业训练","学习能力","社会交往","其他"];
				for(i in method){
					if(measures[method[i]-1]==undefined){
						measures[method[i]-1]=method.Detail;
					}
					$(".measures").append(measures[method[i]-1]+" ");
				}
//				if(method.select==5){
//					$(".measures").text(measures[method.select-1]+"("+method.Detail+")");
//				}else{
//					$(".measures").text(measures[method.select-1]);
//				}
			}
			if(!info.nextClassify==""){
				var nextClass=["不稳定","基本稳定","稳定"];
				$(".nextClass").text(nextClass[info.nextClassify-1]);
			}
			if(!info.nextDate==""){
				$(".nextTime").text(info.nextDate);
			}
			if(!info.doctorSignature==""){
				$(".DoctorSignature").show();
				$(".DoctorSignature li").append("<font><img src='"+info.doctorSignature+"'/></font>");
			}
		}
		electronicArchivesMdule.patientvisitinfo(param,callBack);
	}
	$(".html-loding").hide();
});
